home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
program
/
cluster2.zip
/
SOURCE.ZIP
/
BOXMGR.BU
next >
Wrap
Text File
|
1996-07-06
|
26KB
|
584 lines
$COMPILE UNIT ".\BOXMGR.PBU"
$CODE SEG "SCRNLIB"
$CPU 8086 ' Make compatible with XT systems
$LIB ALL OFF ' Turn off all PowerBASIC libraries
$ERROR ALL OFF ' Turn off all PowerBASIC error checking
$OPTIMIZE SIZE ' Optimize for smaller code
DEFINT A-Z ' Required for all numeric functions, forces PB to not
' include floating point in UNIT (makes it smaller)
'╒═══════════════════════════════════════════════════════════════════════════╕
'│ This library will manage boxes, saving and restoring the │
'│ underlying screen areas as needed. It also has some other │
'│ handy routines, such as a scrolling text viewer, a routine │
'│ to set PowerBASIC's PRINT output to only be in the current box │
'│ │
'│ This code is free for use, but is copyright Nathan C. Durland III │
'│ All rights reserved │
'╞═══════════════════════════════════════════════════════════════════════════╡
'│ Started Jun 10, 1996 -- Bud Durland │
'╞═══════════════════════════════════════════════════════════════════════════╡
'│ Routines are documented with liberal comments in the routine itself │ │
'│ │
'│ However, a quick overview: │
'│ │
'│ This routine will simplify creating and using screen text boxes. │
'│ Each of the routines is pretty well commented and should be │
'│ self-explainatory. Let me touch a couple of the highlights: │
'│ │
'│ 1) always remember to call BoxInit before using any of hte other │
'│ functions listed here. This routine sets up storage arrays │
'│ and etc. │
'│ │
'│ 2) To specify colors, you will be passing the routines attribute │
'│ values, which are a computed using the numeric value of the │
'│ foreground and background colors you want. the │
'│ MakeAttr%(Fore%,Back%) function will compute attributes for │
'│ you. Likewise, the PB3BOXES.INC file has pre-defined │
'│ constants for most of the colors. So, you can do something │
'│ like Box1Attr% = MakeAttr%(%BrightWhite,%Blue) │
'│ │
'│ 3) If you use -1 instead of an attribute value in PrtBox, PrtEOL, │
'│ ClearBox, or BoxTiltle, the default color attribute specified │
'│ when the box was created will be used. │
'│ │
'╘═══════════════════════════════════════════════════════════════════════════╛
DECLARE SUB GetStrLoc() ' internal string locator in RTL
$INCLUDE ".\PB3BOXES.HDR" ' includes defs & declares for all modules.
SUB BoxInit(BYVAL MB%) LOCAL PUBLIC
'╒═══════════════════════════════════════════════════════════════════════╕
'│This sub initializes the arrays used to store window data │
'│ │
'│ MB% is the the maximum numberof boxes you will be using. 5 is the │
'│ default │
'│ │
'╘═══════════════════════════════════════════════════════════════════════╛
CurrentBox% = 0
MaxBoxes% = MB%
IF MaxBoxes% < 1 THEN MaxBoxes% = 5
DIM BoxParms%(1:MaxBoxes%,1:6) ' stores Size, Color, & border type
DIM SaveText$(1:MaxBoxes%) ' stores saved text
DIM BorderText$(0:3) ' Different box borders
BorderText$(0) = CHR$( 32, 32, 32, 32, 32, 32) ' no border
BorderText$(1) = CHR$(196,179,218,191,192,217) ' single
BorderText$(2) = CHR$(205,186,201,187,200,188) ' double
BorderText$(3) = CHR$(219,219,219,219,219,219) ' Solid
END SUB
SUB MakeBox(BYVAL Row%, BYVAL Col%, BYVAL Rows%, BYVAL Cols%, _
BYVAL BoxAttr%, BYVAL Border%) LOCAL PUBLIC
'╒══════════════════════════════════════════════════════════════════════════╕
'│ MAKEBOX -- put a box on the screen. underlying text is preserved │
'│ so it can be put back by the RemoveBox routine │
'│ │
'│Row% = Top row of box │
'│Col% = Left column │
'│Rows% = length of box │
'│Cols% = Width of box │
'│BoxAttr% = color attribute for box │
'│Border% = border style to use 0-None 1-single 2-double 3-Solid │
'│ Add 10 to value for "3-d" border │
'╘══════════════════════════════════════════════════════════════════════════╛
IF CurrentBox% = MaxBoxes% THEN EXIT SUB ' no more room for making boxes.
IF Border% < 0 THEN Border% = 1
INCR CurrentBox%,1 ' bump box number
BoxParms%(CurrentBox%,1) = Row% ' Save infor about Box
BoxParms%(CurrentBox%,2) = Col%
BoxParms%(CurrentBox%,3) = Rows%
BoxParms%(CurrentBox%,4) = Cols%
BoxParms%(CurrentBox%,5) = BoxAttr%
BoxParms%(CurrentBox%,6) = Border% MOD 10
lAttr% = BoxAttr%
' Get component colors of box attribute for use in 3d effects
IF Border% > 9 THEN
CALL ReturnAttr(BoxAttr%, TheFore%, TheBack%)
IF TheFore% = TheBack% THEN ' caller wants same fore & back colors
LowFore% = TheFore% ' Why? Dunno, but we'll let it happen
HiFore% = TheFore%
ELSE
LowFore% = TheFore% MOD 8 ' low intesity colors are < 8
HiFore% = LowFore% + 8 ' high intensity is => 8
END IF
lAttr% = MakeAttr%(LowFore%,TheBack%)
hAttr% = MakeAttr%(HiFore%,TheBack%)
END IF
' Save the underlying text, then create the box!
temp$ = ""
CALL QSAVE(Row%, Col%, Rows%, Cols%, temp$)
SaveText$(CurrentBox%) = temp$
CALL QBOX(Row%, Col%, Rows%, Cols%, lAttr%, (Border% MOD 10))
IF Border% > 10 THEN
CALL QATTR((Row% + Rows%)-1,Col%,1,Cols%,hAttr%)
CALL QATTR(Row%+1,(Col%+Cols%)-1,Rows%-1,1,hAttr%)
END IF
END SUB
SUB RemoveBox LOCAL PUBLIC
'╒═════════════════════════════════════════════════════════════════════╕
'│ RemoveBox -- Takes a box off the screen, and replaces it with the │
'│ saved underlying data │
'╘═════════════════════════════════════════════════════════════════════╛
IF CurrentBox% < 1 THEN EXIT SUB
Row% = BoxParms%(CurrentBox%,1)
Col% = BoxParms%(CurrentBox%,2)
Rows% = BoxParms%(CurrentBox%,3)
Cols% = BoxParms%(CurrentBox%,4)
temp$ = SaveText$(CurrentBox%)
CALL QREST(Row%, Col%, Rows%, Cols%, temp$)
DECR CurrentBox%
END SUB
SUB ClearBox(BYVAL Char%, BYVAL Attr%) LOCAL PUBLIC
'╒════════════════════════════════════════════════════════════════════════════╕
'│ Clears the current box using the specified character and attribute │
'╞════════════════════════════════════════════════════════════════════════════╡
'│Char% -- ASCII value of character to use. If < 0, a space is used. │
'│Attr% -- Color attribute to use. if < 0, the default for the box is used │